<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .widthF {
            width: 300px;
            height: 300px;
            background: red;
        }

        .widthS {
            width: 100px;
            height: 100px;
            background: gray;
        }

        .father_3 {
            position: relative;
        }
         /* 先相对父元素移动50%在向右移动子元素自身的宽度 */
        .son_3 {
            position: absolute;
            left: calc(50% - 50px);
            top: calc(50% - 50px);
        }
    </style>
</head>

<body>
    <!-- 使用calc计算属性计算left top的值达到居中的效果 需要知道子元素的宽高 -->
    <div class="widthF father_3">
        <div class="widthS son_3">

        </div>
    </div>
</body>

</html>